package cn.com.code.hwjs;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

/**
 * @author zhengpei
 * @date 2022/4/30
 * https://www.nowcoder.com/practice/f9a4c19050fc477e9e27eb75f3bfd49c?tpId=37&tqId=21264&rp=1&ru=/exam/oj&qru=/exam/oj&sourceUrl=%2Fexam%2Foj%3Fdifficulty%3D3%26page%3D1%26pageSize%3D50%26search%3D%26tab%3D%25E5%2590%258D%25E4%25BC%2581%25E7%25AC%2594%25E8%25AF%2595%25E7%259C%259F%25E9%25A2%2598%26topicId%3D37&difficulty=3&judgeStatus=undefined&tags=&title=
 */
public class Hwjs41 {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (sc.hasNext()) {
      int n = sc.nextInt();

      int[] M = new int[n];
      int[] X = new int[n];

      for (int i = 0; i < n; i++) {
        M[i] = sc.nextInt();
      }
      for (int i = 0; i < n; i++) {
        X[i] = sc.nextInt();
      }
      HashSet<Integer> set = new HashSet<>();
      //关键点就是set必须手动添加一个元素，从而进入循环，添加元素。
      set.add(0);


      for (int i = 0; i < n; i++) {
        List<Integer> list = new ArrayList<>(set);
        for (int j = 1; j <= M[i]; j++) {
          for (int k = 0; k < list.size(); k++) {
            set.add(list.get(k) + X[i] * j);
          }
        }

      }
      System.out.println(set.size());
    }

  }

}

